import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'BookStore',
    meta:{
      title:"Lemon商城"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/BookStore.vue')
  },
  {
    path: '/MyHome',
    name: 'MyHome ',
    meta:{
      title:"我的"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/MyHome.vue')
  },
  {
    path: '/About',
    name: 'about ',
    meta:{
      title:"关于我们"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path: '/UserManagement',
    meta:{
      title:"账号管理"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/UserManagement.vue')
  },
  {
    path: '/UserLogin',
    name: 'UserLogin',
    meta:{
      title:"用户登录"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/UserLogin.vue')
  },
  {
    path: '/UserRegist',
    name: 'UserRegist ',
    meta:{
      title:"用户注册"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/UserRegist.vue')
  },
  {
    path: '/AdressSet',
    name: 'AdressSet',
    meta:{
      title:"地址管理"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/AdressSet.vue')
    
  }, 
  {
    path: '/AddAdress',
    name: 'AddAdress',
    meta:{
      title:"新增地址"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/AddAdress.vue')
    
  }, 
  {
    path: '/EditAdress/:Aid',
    name: 'EditAdress',
    meta:{
      title:"编辑地址"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/EditAdress.vue')
    
  }, 
  {
    path: '/ProductDetail',
    name: 'Product',
    meta:{
      title:"商品详情"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/ProductDetails.vue')
  },
  {
    path: '/ShopList',
    name: 'ShopList',
    meta:{
      title:"商品分类"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/ShopList.vue')
  },
  {
    path: '/MyOrder',
    name: 'MyOrder',
    meta:{
      title:"我的订单"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/MyOrder.vue')
  },
  {
    path: '/ShoppingCart',
    name: 'ShoppingCart',
    meta:{
      title:"购物车"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/ShoppingCart.vue')
  },
  {
    path: '/OrderDetails/:oid',
    name: 'OrderDetails',
    meta:{
      title:"订单详情"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/OrderDetails.vue')
  }, 
  {
    path: '/GenerateOrder/:oid',
    name: 'GenerateOrder',
    meta:{
      title:"生成订单"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/GenerateOrder.vue')
  }, 
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router
